﻿package  com.mattlohkamp.src.as3{
	import flash.utils.Proxy;
    import flash.utils.flash_proxy;

    dynamic class ProxyArray extends Proxy {
        private var _item:Array;

        public function ProxyArray() {
            _item = new Array();
        }

        override flash_proxy function callProperty(methodName:*, ... args):* {
            var res:*;
            res = _item[methodName].apply(_item, args);
            return res;
        }

        override flash_proxy function getProperty(name:*):* {
            if(!isNaN(name)) {
                var index:int = name;
                while(index < 0) {
                    index += this.length;

                }
                return _item[index % this.length];
            }


            return _item[name];
        }

        override flash_proxy function setProperty(name:*, value:*):void {
            _item[name] = value;
        }
    }

}